/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.wallet.online.jwt;

/**
 * This bean class represents cart line items for the {@link FullWalletRequest}.  These line items
 * will be stored in receipts for customers to review
 *  
 * @author pying (peng ying)
 * 
 */
public class LineItem {
  private String description;
  private Integer quantity;
  private String unitPrice;
  private String totalPrice;
  private String role;
  private Boolean isDigital;
  
  public enum Role {TAX, SHIPPING};

  /**
   * Default constructor
   */
  public LineItem() {
  }

  /**
   * Constructor that defines basic properities of an item
   * 
   * @param desc Item description
   * @param quantity Item quantity
   * @param price Item price in xxx.xx format
   * @param currency Item currency in 3 character ISO 4217 format
   */
  public LineItem(String desc, Integer quantity, String price) {
    this.description = desc;
    this.quantity = quantity;
    this.unitPrice = price;
    this.totalPrice = ((Double)(quantity * Double.valueOf(price))).toString();
  }

  /**
   * Getter for description
   * 
   * @return Item description
   */
  public String getDescription() {
    return description;
  }

  /**
   * Setter for description
   * 
   * @param description Item description
   */
  public void setDescription(String description) {
    this.description = description;
  }

  /**
   * Getter for item quantity
   * @return Item quantity
   */
  public Integer getQuantity() {
    return quantity;
  }

  /**
   * Setter for item quantity
   * Updates the total price
   * 
   * @param quantity Item quantity
   */
  public void setQuantity(Integer quantity) {
    this.quantity = quantity;
    setTotalPrice(((Double)(quantity * Double.valueOf(getUnitPrice()))).toString());
  }

  /**
   * Getter for item price
   * 
   * @return Item price
   */
  public String getUnitPrice() {
    return unitPrice;
  }

  /**
   * Setter for item price
   * 
   * @param unit_price Item price
   */
  public void setUnitPrice(String unit_price) {
    this.unitPrice = unit_price;
    setTotalPrice(((Double)(quantity * Double.valueOf(unit_price))).toString());
  }

  /**
   * Getter for total line item price
   * 
   * @return Total line item price(unit price * quantity)
   */
  public String getTotalPrice() {
    return totalPrice;
  }

  /**
   * Setter for total line item price
   * 
   * @param total_price Total line item price
   */
  public void setTotalPrice(String total_price) {
    this.totalPrice = total_price;
  }

  /**
   * Getter for role which allows you to define the role of the line item ie shipping, tax, item
   * 
   * @return Role
   */
  public String getRole() {
    return role;
  }

  /**
   * Setter for role which allows you to define the role of the item ie shipping, tax, item
   * 
   * @param role Role
   */
  public void setRole(Role role) {
    /*switch(role){
      case shipping:
        this.role = 1;
        break;
      case tax:
        this.role = 2;
        break;
    }*/
    
    this.role = role.toString();
  }

  public Boolean getIsDigital() {
    return isDigital;
  }

  public void setIsDigital(Boolean isDigital) {
    this.isDigital = isDigital;
  }
}
